<?php

namespace App\Http\Requests;

class Adsense extends Base
{

    public function rules()
    {
        $id = $this->get('id');
        $rules = [
            //unique:表名,字段名,排除ID,主键字段,条件字段,条件,
            'title' => 'required',
            'name' => 'required|regex:/^[A-Z_]+$/|unique:adsenses,name,'.$id,
            'width' => 'required|integer',
            'height' => 'required|integer',
        ];
        return $rules;

    }

    public function messages()
    {
        return [
            'title.required' => '请填写广告位名称',
            'name.required' => '请填写广告位标识',
            'name.regex' => '广告位标识必须是大写字母/下划线',
            'name.unique'   => '广告位标识已存在',
            'width.required' => '请填写广告位图片尺寸',
            'width.integer'   => '广告位图片尺寸必须是整型',
            'height.required' => '请填写广告位图片尺寸',
            'height.integer'   => '广告位图片尺寸必须是整型',
        ];
    }
}
